﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Interfaces.CommonData;

namespace StockInfoLoader
{
    public class IndexCompositionLoader
    {
        private string _AllStocks = @"AAPL|Apple Inc.
ABT|Abbott Laboratories
ACN|Accenture plc
AEP|American Electric Power Co.
AIG|American International Group Inc.
ALL|Allstate Corp.
AMGN|Amgen Inc.
AMZN|Amazon.com
APA|Apache Corp.
APC|Anadarko Petroleum Corporation
AXP|American Express Inc.
BA|Boeing Co.
BAC|Bank of America Corp
BAX|Baxter International Inc
BK|Bank of New York
BMY|Bristol-Myers Squibb
BRK.B|Berkshire Hathaway
C|Citigroup Inc
CAT|Caterpillar Inc
CL|Colgate-Palmolive Co.
CMCSA|Comcast Corporation
COF|Capital One Financial Corp.
COP|ConocoPhillips
COST|Costco
CSCO|Cisco Systems
CVS|CVS Caremark
CVX|Chevron
DD|DuPont
DELL|Dell
DIS|The Walt Disney Company
DOW|Dow Chemical
DVN|Devon Energy
EBAY|eBay Inc.
EMC|EMC Corporation
EMR|Emerson Electric Co.
EXC|Exelon
F|Ford Motor
FCX|Freeport-McMoran
FDX|FedEx
GD|General Dynamics
GE|General Electric Co.
GILD|Gilead Sciences
GM|General Motors
GOOG|Google Inc.
GS|Goldman Sachs
HAL|Halliburton
HD|Home Depot
HON|Honeywell
HPQ|Hewlett Packard Co
IBM|International Business Machines
INTC|Intel Corporation
JNJ|Johnson & Johnson Inc
JPM|JP Morgan Chase & Co
KO|The Coca-Cola Company
LLY|Eli Lilly and Company
LMT|Lockheed-Martin
LOW|Lowe's
MA|MastercardInc
MCD|McDonald's Corp
MDLZ|Mondelez International
MDT|Medtronic Inc.
MET|Metlife Inc.
MMM|3M Company
MO|Altria Group
MON|Monsanto
MRK|Merck & Co.
MS|Morgan Stanley
MSFT|Microsoft
NKE|Nike
NOV|National Oilwell Varco
NSC|Norfolk Southern Corp
NWSA|News Corp.
ORCL|Oracle Corporation
CTS|Cognizant
OXY|Occidental Petroleum Corp.
PEP|Pepsico Inc.
PFE|Pfizer Inc
PG|Procter & Gamble Co
PM|Phillip Morris International
QCOM|Qualcomm Inc.
RTN|Raytheon Co (NEW)
SBUX|Starbucks Corporation
SLB|Schlumberger
SO|Southern Company
SPG|Simon Property Group, Inc.
T|AT&T Inc
TGT|Target Corp.
TWX|Time Warner Inc.
TXN|Texas Instruments
UNH|UnitedHealth Group Inc.
UNP|Union Pacific Corp.
UPS|United Parcel Service Inc
USB|US Bancorp
UTX|United Technologies Corp
V|Visa Inc.
VZ|Verizon Communications Inc
WAG|Walgreens
WFC|Wells Fargo
WMB|Williams Companies
WMT|Wal-Mart";
//XOM|Exxon Mobil Corp";

        public List<Stock> LoadIndexComposition(IndexName idxName)
        {


            //TODO: currently fixed list. Need to load from the site
            List<Stock> lstStocks = new List<Stock>();
            int c = 0;

            using (System.IO.StringReader sr = new StringReader(_AllStocks))
            {
                string line = sr.ReadLine();
                while (line != null)
                {
                    string[] values = line.Split('|');
                    lstStocks.Add(new Stock() { CompanyName = values[1].Replace("'", "''"), Id = ++c, Ticker = values[0] });
                    line = sr.ReadLine();
                } 
                
            }

            return lstStocks;
        }
    }
}
